package by.apiskun.curex.datamodel;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

@Entity
public class ChangeRate extends AbstractEntity {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long changeRateId;

	@Column
	@NotNull
	@Max(value = 99999)
	@Min(value = 0)
	private Double changeRateCourse;

	@Column
	private Date startDate;

	@Column
	@NotNull
	private Date endDate;

	@ManyToOne(fetch = FetchType.LAZY, targetEntity = Money.class)
	@JoinColumn(name = "money_name_before")
	private Money moneyNameBefore;

	@ManyToOne(fetch = FetchType.LAZY, targetEntity = Money.class)
	@JoinColumn(name = "money_name_after")
	private Money moneyNameAfter;

	public Double getChangeRateCourse() {
		return changeRateCourse;
	}

	public void setChangeRateCourse(Double changeRateCourse) {
		this.changeRateCourse = changeRateCourse;
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public Money getMoneyNameBefore() {
		return moneyNameBefore;
	}

	public void setMoneyNameBefore(Money moneyNameBefore) {
		this.moneyNameBefore = moneyNameBefore;
	}

	public Money getMoneyNameAfter() {
		return moneyNameAfter;
	}

	public void setMoneyNameAfter(Money moneyNameAfter) {
		this.moneyNameAfter = moneyNameAfter;
	}

	public void setChangeRateId(Long changeRateId) {
		this.changeRateId = changeRateId;
	}

	@Override
	public Long getId() {
		return changeRateId;
	}
}
